package com.graduation.mybatis.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 
 * @TableName plan_foods
 */
@TableName(value ="plan_foods")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PlanFoods implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 
     */
    private Integer planId;

    /**
     * 
     */
    private Integer foodId;

    /**
     * 1-早餐, 2-午餐, 3-晚餐, 4-加餐
     */
    private Integer mealType;

    /**
     * 计划摄入克数
     */
    private Double grams;

    /**
     * 1-7表示周一到周日，NULL表示每天
     */
    private Integer dayOfWeek;

    public PlanFoods(Integer planId, Integer foodId, Integer mealType, Double grams) {
        this.planId = planId;
        this.foodId = foodId;
        this.mealType = mealType;
        this.grams = grams;
    }

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;


    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        PlanFoods other = (PlanFoods) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getPlanId() == null ? other.getPlanId() == null : this.getPlanId().equals(other.getPlanId()))
            && (this.getFoodId() == null ? other.getFoodId() == null : this.getFoodId().equals(other.getFoodId()))
            && (this.getMealType() == null ? other.getMealType() == null : this.getMealType().equals(other.getMealType()))
            && (this.getGrams() == null ? other.getGrams() == null : this.getGrams().equals(other.getGrams()))
            && (this.getDayOfWeek() == null ? other.getDayOfWeek() == null : this.getDayOfWeek().equals(other.getDayOfWeek()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getPlanId() == null) ? 0 : getPlanId().hashCode());
        result = prime * result + ((getFoodId() == null) ? 0 : getFoodId().hashCode());
        result = prime * result + ((getMealType() == null) ? 0 : getMealType().hashCode());
        result = prime * result + ((getGrams() == null) ? 0 : getGrams().hashCode());
        result = prime * result + ((getDayOfWeek() == null) ? 0 : getDayOfWeek().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", planId=").append(planId);
        sb.append(", foodId=").append(foodId);
        sb.append(", mealType=").append(mealType);
        sb.append(", grams=").append(grams);
        sb.append(", dayOfWeek=").append(dayOfWeek);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}